package pro.model.core;

import java.awt.*;
import java.util.*;

/**
 * @author  sangwo.y
 */
public class Card {

	/**
	 * @author  sangwo.y
	 */
	public enum Suit { Spade, Diamond, Heart, Club }
	/**
	 * @author  sangwo.y
	 */
	public enum Value { Ace, King, Queen, Jack, Ten, Nine, Eigth, Seven, Six, Five, Four, Three, Two }
	
	private Suit suit;
	private Color color; 
	private Value value;
	
//	private static Map<Value, Value> outRules;
//	
//	static {
//		outRules.put(Ace, arg1)
//	}
//	
	public Card(Suit suit, Value value) {
		this.suit=suit; this.value=value;
		switch (suit) {
			case Spade: color = Color.BLACK; break;
			case Club: color = Color.BLACK; break;
			default: color = Color.RED;
		}
	}
	
	/**
	 * @return  the suit
	 * @uml.property  name="suit"
	 */
	public Suit getSuit() {
		return suit;
	}
	
	/**
	 * @return  the value
	 * @uml.property  name="value"
	 */
	public Value getValue() {
		return value;
	}
	
	/**
	 * @return  the color
	 * @uml.property  name="color"
	 */
	public Color getColor() {
		return color;
	}
	
	public boolean isNext(Card card) {
		
		if (!color.equals(card.getColor())) {
			int ord = value.ordinal();
			if (card.getValue().ordinal()==(ord+1)) 
				return true;
		}
		return false;
	}
	
	
	public boolean isSameNext(Card card) {
		if (	(suit.equals(card.getSuit())) 
				&&
					(	
					((value.equals(Value.Ace)) &&	(card.value.equals(Value.Two)))
					||		
					(card.getValue().ordinal()==(value.ordinal()-1))
					)
				
		) return true;
		 
		return false;
	}
	
	public String toString() {
		String col;
		if (color==Color.RED) {
			col = "R";
		} else {
			col="B";
		}
//		return value+"Of"+suit+"("+col+")";
		return value+"Of"+suit;
	}
}
